package com.aiju.common.http.interceptor;


import com.aiju.app.DataProviderManager;
import com.aiju.app.IDataProvider;
import com.aiju.common.network.NetState;
import com.aiju.support.aop.AInterceptor;
import com.aiju.support.aop.AInterceptorHandler;
import com.aiju.utils.T;

import java.lang.reflect.Method;


/**
 * @author: 佐为
 * @date: 2017-03-24 12:02
 * @version: V1.0
 * @Description: 网络拦截
 */
public class NetWorkInterceptor extends AInterceptor {
    @Override
    protected void addMetodName() {
        methods.add("requestPost");
        methods.add("requestGet");
    }

    @Override
    protected Object interceptor(Object proxied, Method method, Object[] args) {
        IDataProvider dataProvider = DataProviderManager.getDataProvider();
        if (dataProvider.getNetType() == NetState.NETWORN_NONE) {
            T.ToastShort("当前无网络，请检查网络设置");
            return AInterceptorHandler.END;
        }
        return AInterceptorHandler.DEFAULT;
    }
}
